chore: refactor Algebra.TensorProduct.rightAlgebra#39699
Conversation
PR summary cd84f88c8eImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
|
Comments from #25481 : Me: The reason all the changes are there is that I define smul at the same time as defining the Algebra instance. The smul isn't an instance so I avoided making it. Another approach is to define rightAlgebra_smul : SMul A (A ⊗[R] B), make it locally an instance, make some API for it (some simp lemmas e.g. smul_def), and then tidy the proofs up a bit. But I was a bit concerned about making simp lemmas which only fired for a scalar multiplication which wasn't an instance so I decided to mess with simp as little as possible. I did add one simp lemma for rightAlgebra though; this was to make a proof which was added in #22933 compile again. I could remove the simp lemma and fix the #22933 proof in a different way (probably with another change) or I could alternatively add more simp lemmas about these not-usually-instances. I wasn't sure which way to go so we now have some kind of half-way house. Me (after the old PR was delegated to me -- but I didn't merge): @eric-wieser this has been delegated to me but I am reluctant to merge because IIRC we had a discussion about this on Zulip and you were not enthusiastic about the change: your specific comment is here #mathlib4 > Right actions on tensor products (again) @ 💬 and I don't want to be the intentional causer of trouble. I do not understand the issues well enough to understand your comment properly. |
|
I've just reread the long thread #mathlib4 > Right actions on tensor products (again) @ 💬 again and what it seems to be is a lot of stuff which is irrelevant to this PR, and then Andrew suggesting this approach, and then Eric saying "I think pulling through comm is going to cause trouble in an eventual bimodule world, where you can't commute without also moving to MulOpposite". |
(was #25481 ; now re-opened from a fork).
The declaration
Algebra.TensorProduct.rightAlgebramakesA ⊗[R] Binto aB-algebra (hereRis aCommSemiring,Ais aSemiringand anR-algebra, andBis aCommSemiringand anR-algebra). It is not an instance because if A = B it causes a diamond. However in the many cases where A isn't B, it can occasionally be useful.However one could imagine that in the many cases where an R-module
Malso isn'tB, it might occasionally be useful to makeM ⊗[R] Binto aB-module (and indeed I am finding this in FLT). With the current definition ofAlgebra.TensorProduct.rightAlgebrathis is difficult to do without causing diamonds in the case whenMhappens to be anR-algebra.One fix for this is just to redefine
Algebra.TensorProduct.rightAlgebraso that thesmulfield isi.e. literally "swap the product around, use mathlib's instance making
B ⊗[R] Ainto aB-algebra, and then swap back". Then the same definition can be used to makeM ⊗[R] Binto aB-module and on the odd occasion where this point of view is useful, there is no diamond. This is what we do in this PR. After adding one simp lemma there is no breakage at all in mathlib. Furthermore, for those who have observed that we want to build on this algebra instance sometimes and, for example, add instances of the form "if M is finite over R then M ⊗[R] B is finite over B" -- these instances are really easy to add now with this new definition, because you simply pull back the analogous finite left module instance along the isomorphism M ⊗[R] B = B ⊗[R] M. Examples (from FLT, where the right action is put in a scope):